import type { RouteRecordRaw } from 'vue-router'
import Layout from '@/Layouts/index.vue'
import NotFindPage from '@/Layouts/NotFindPage.vue'

const files = require.context('./modules', false, /\.ts$/)

const modules = files.keys().reduce((modules: any, path) => {
  const module = files(path); 
  modules.push( module.default || {});
  return modules;  
}, []);

export const asyncRouters: RouteRecordRaw[] = [...modules]


const Layouts: RouteRecordRaw = {
  path: '/',
  redirect: '/home',
  component: Layout,
  children: asyncRouters
}

const NotFindPages: RouteRecordRaw = {
  path: '/*',
  component: NotFindPage
}

export const baseRouters = [ Layouts , NotFindPages ]
